﻿using System;
using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.Timeline;

namespace IQIGame.Onigao.GamePlay
{
    [Serializable]
    public class BattleHideClip : PlayableAsset, ITimelineClipAsset
    {
        [Flags]
        public enum EBattleHideType
        {
            [InspectorName("自己")] Self = 1 << 0,
            [InspectorName("目标")] Target = 1 << 1,
            [InspectorName("友军")] Friend = 1 << 2,
            [InspectorName("敌军")] Enemy = 1 << 3,
            [InspectorName("场景")] Scene = 1 << 4,
            [InspectorName("UI")] UI = 1 << 5,

            [InspectorName("默认")] Default = Self | Scene | UI,
        }

        [Tooltip("隐藏排除类型")] [SerializeField] public EBattleHideType exceptType = EBattleHideType.Default;
        [SerializeField] public int effectiveIndex;
        [SerializeField] public bool onlyWidget;
        public override double duration => 2.0;

        public ClipCaps clipCaps
        {
            get => ClipCaps.None;
        }

        public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
        {
            var rPlayable = ScriptPlayable<BattleHideBehaviour>.Create(graph);
            BattleHideBehaviour clone = rPlayable.GetBehaviour();
            clone.exceptType = this.exceptType;
            clone.effectiveIndex = this.effectiveIndex;
            clone.entityDriver = owner.GetComponent<EntityDriver>();
            clone.onlyWidget = this.onlyWidget;
            return rPlayable;
        }
    }
}